const enum State {
  V1,
  V2,
}

/**
 * - yields numbers
 * - returns strings
 * - can be passed in booleans
 */
function* counter(): Generator<number, string, boolean> {
  let i = 0;
  while (true) {
    if (yield i++) {
      break;
    }
  }
  return 'done!';
}

var iter = counter();
var curr = iter.next();
var endFn = (curr: IteratorYieldResult<number>) => curr.value === 5;
while (!curr.done) {
  // { value: T, done: false}
  console.log(curr.value);
  // 依赖反转，由迭代器的值停止迭代器的执行
  curr = iter.next(endFn(curr));
}
// { value: TReturn, done: true}
console.log(curr.value.toUpperCase());

// prints:
//
// 0
// 1
// 2
// 3
// 4
// 5
// DONE!

type FloatZero = 0;
//        ^?

type FFFF = 0xff_ff;
//     ^?
